from my import *
from .utils import *

toolname = getToolName()

import optparse,pathlib,os
import pyperclip as pc

parser = optparse.OptionParser("")
parser.add_option("-f",  '--filePath', dest="filePath", default = "x")
parser.add_option("-c",  '--useCopyExclude', action='store_true', dest="useCopy", default = False)
options, args = parser.parse_args()
filePath = pathlib.Path(options.filePath)
# tar -cvkf ngreact_.tar --exclude .* --exclude=ngreact/node_modules ngreact
"""
*/node_modules
*/package-lock.json
*/dist
.DS_Store
.umi*
/.env.local
"""
def func(isHelp=False):
    if(isHelp):return [toolname,"~ %s file "%(toolname),"#tar with exclude"]
    argv = getToolArgv()
    
    excludes = ''
    if(options.useCopy):
        excludes = map(lambda x: '--exclude='+x.strip(), pc.paste().split("\n"))
    cmd = 'tar -cvkf %s %s %s' % (
        filePath.stem + '_' + filePath.suffix + '.tar',
        ' '.join(list(excludes)),
        str(filePath)
    )
    print(cmd)
    os.system(cmd)